
ALTER            procedure  sp_insert_contact_person_for_existing_customers

as
begin
	declare @customer_Id int
	declare @contact_person varchar(50)
	

		delete from Customer_Contact_Persons_Table
		declare insert_contact_person CURSOR For
		SELECT  Customer_ID , C_Contact_Person  FROM Customer 
		
		open insert_contact_person		
		fetch next from  insert_contact_person into  @customer_Id , @contact_person 
		
		while @@fetch_status = 0
		begin
				if( @contact_person <> '' and @contact_person is not NULL )
				begin
					--modified by Sarada on 15th April 2004
					--insert into Contact_Persons_Table (Customer_Id , Contact_Person , Phone_Number , Cell_Number , Fax , Email , Deactivated  )values (@customer_Id , @contact_person ,'' , '' , '', '', 0 )
					insert into Customer_Contact_Persons_Table (Customer_Id , Contact_Person , Phone_Number , Cell_Number , Fax , Email , Deactivated  )values (@customer_Id , @contact_person ,'' , '' , '', '', 0 )
				end
				fetch next from insert_contact_person into @customer_Id , @contact_person 

		end 

		close insert_contact_person
		deallocate insert_contact_person

		--select * from Contact_Persons_Table
		select * from Customer_Contact_Persons_Table
 

END

